#ifndef __GAF_UTILITY_H__
#define __GAF_UTILITY_H__

#include <math.h>

#ifdef M_PI
#define GAF_MATH_PI			M_PI
#else
#define GAF_MATH_PI			3.14159265358979323846
#endif

/// 绝对值操作
#define GAF_MATH_ABS(_nNum)		((_nNum) >=0 ? (_nNum) : -(_nNum))
/// 最大值操作
#define GAF_MATH_MAX(_nNum1, _nNum2)	(((_nNum1) > (_nNum2)) ? (_nNum1) : (_nNum2))
/// 最小值操作
#define GAF_MATH_MIN(_nNum1, _nNum2)	(((_nNum1) < (_nNum2)) ? (_nNum1) : (_nNum2))
/// 中间值操作
#define GAF_MATH_MID(_nNum1, _nNum2)	(((_nNum1) + (_nNum2)) >> 1)

/// 打位标记操作
#define GAF_DOMARK(_bState, _nID)	((_bState) |= (0x1 << (_nID)))
/// 撤销位标记操作
#define GAF_UNMARK(_bState, _nID)	((_bState) &= ~(0x1 << (_nID)))
/// 查看位标记操作
#define GAF_ISMARK(_bState, _nID)	((((_bState) >> (_nID)) & 0x1) == 0x1)

/// 弧度到角度
#define GAF_MATH_RADIAN2ANGLE(_dRadian)	(_dRadian * 180 / GAF_MATH_PI)
/// 角度到弧度
#define GAF_MATH_ANGLE2RADIAN(_nAngle)	(_nAngle * GAF_MATH_PI / 180)


#define GAF_MATH_DISTANCE		GAF::Math::Distance

#define GAF_MATH_WAY			GAF::Math::Way


namespace GAF
{
	class Math
	{
		static int		Distance(int nX1, int nY1, int nX2, int nY2);
		static int		Way(int nBeginX, int nBeginY, int nEndX, int nEndY);
	};
}

#endif
